home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Hyper / Rinaldi / HC 1.2 & 2.0 / Menu 2.1.cpt / Menu 2.1 / card_3055.txt < prev    next >
Text File  |  1991-08-18  |  13KB  |  332 lines

  1. -- card: 3055 from stack: in.1
  2. -- bmap block id: 3273
  3. -- flags: 0000
  4. -- background id: 2661
  5. -- name: 
  6. ----- HyperTalk script -----
  7. on doMenu What
  8.   if What is in "Item 1,Item 2,Item 3"
  9.   then answer "You called menu ‚Äú" & What & "‚Äù"
  10. else pass doMenu
  11. end doMenu
  12.  
  13. on DoMenuXCMD
  14.   do card field "Cmd"
  15.   get the Result
  16.   if it ‚↠empty
  17.   then answer it
  18. end DoMenuXCMD
  19.  
  20.  
  21.  
  22. -- part 1 (field)
  23. -- low flags: 01
  24. -- high flags: 0007
  25. -- rect: left=69 top=68 right=252 bottom=434
  26. -- title width / last selected line: 0
  27. -- icon id / first selected line: 0 / 0
  28. -- text alignment: 0
  29. -- font id: 3
  30. -- text size: 9
  31. -- style flags: 0
  32. -- line height: 12
  33. -- part name: 
  34.  
  35.  
  36. -- part 26 (button)
  37. -- low flags: 00
  38. -- high flags: A003
  39. -- rect: left=200 top=278 right=317 bottom=336
  40. -- title width / last selected line: 0
  41. -- icon id / first selected line: 0 / 0
  42. -- text alignment: 1
  43. -- font id: 0
  44. -- text size: 12
  45. -- style flags: 0
  46. -- line height: 16
  47. -- part name: Test Menu XCMD
  48. ----- HyperTalk script -----
  49. on mouseUp
  50.   go next
  51. end mouseUp
  52.  
  53.  
  54.  
  55. -- part contents for card part 1
  56. ----- text -----
  57.  
  58.                                                   Menu 2.1
  59.                                                   --------
  60.  
  61.                                   ¬© Fr√©d√©ric Rinaldi 1989,1990
  62.  
  63.                Special thanks to Eric Ruff for his faithfully beta-testing.
  64.  
  65.  
  66.    Menu 2.1 is the evolution of the well known MenuSet package. Plenty of enhancements have been added, in order to make Menu XCMD the most powerful and easy to use menu external ever used.
  67.  
  68. Major enhancements are :
  69.  
  70. ‚Ä¢ The whole set has been compiled in just one XCMD of 16 Kb (26 Kb for 11 
  71.    externals before).
  72. ‚Ä¢ Each item or subitem name is now parsed, in order to remove special 
  73.    formatting codes. Thus, "<B^257Item!‚àö" is same as "item" for the XCMD.
  74. ‚Ä¢ Special formatting codes can be used in any command parameter.
  75. ‚Ä¢ Menu, item, subitem names and Command chars are automatically 
  76.    capitalized to preserve Human Interface Guidelines
  77. ‚Ä¢ The syntax has been homogenized in all commands :
  78.                  Menu <command>,<menu>,<item>,<subitem>
  79.    and when an additional param is needed, it is always in second place :
  80.                  Menu <command>,<special>,<menu>,<item>,<subitem>
  81.    So, you need now to specify the whole path for a subitem, the XCMD 
  82.    doesn't search anymore in menu, then submenu list of items. This allows 
  83.    now to have many identical subitems in a same menu.
  84. ‚Ä¢ For any item or subitem param, you can use either its name, or its number.
  85. ‚Ä¢ Everything has been forecast to prevent suppression of user File menu or 
  86.    of its Quit item, and any modification out of guidelines of this item.
  87. ‚Ä¢ Install can now even install the File menu. In this case, it will add all the 
  88.    supplied items before the quit item.
  89. ‚Ä¢ Switch accepts now About and Help items that go under the Apple menu.
  90. ‚Ä¢ Many commands have been added to deal with item command, style, ICON or even SICN.
  91. ‚Ä¢ Extensive online help is available (you have to get the Result after calling to obtain the help text) :
  92.    typing           Menu "!" 
  93.    will return   "Version 2.1, ¬© Frederic RINALDI 1989,1990,1991"
  94.    Typing          Menu "?" 
  95.    will return   "Type ‚ÄúMenu "?",<command>‚Äù to get help on a command"
  96.    Typing          Menu "?",<command>
  97.    will return   syntax help for that command.
  98.    Typing          Menu "=" 
  99.    will return   "<error> if any OR <ICON|SICN id> OR <styles list> OR <
  100.                        shortcut char> OR <menus count>"
  101. ‚Ä¢ When "*" is allowed anywhere in the syntax, it means either "all" most of the time, or "end" for Insert command.
  102. ‚Ä¢ The menu definition can now use either return or semi-colon as separator.
  103. ‚Ä¢ A special hack has been provided to allow SICN inserting using special 
  104.    formatting chars (like ^xxx for an ICON).
  105. ‚Ä¢ Menu is fully international, giving the right "File" and "Quit" name when you call Switch.
  106.  
  107. And, like for MenuSet 1.0 :
  108.  
  109. ‚Ä¢ Menu 2.1 remains the only XCMD allowing to remove all HC menus 
  110.    except Apple, File & Edit menu. The File menu is fully customizable, and 
  111.    the Edit menu still allows Cut, Copy & Paste.
  112. ‚Ä¢ Even really powerful, it remains a simple to use as any HyperTalk 
  113.    statement. You will never have to deal with dummy menu IDs stored in 
  114.    global variables, just pass the names and it will do it for you.
  115. ‚Ä¢ Finally, like all of my externals, I will support it and regularly enhance it.
  116.  
  117.  
  118.                                              HOW TO USE IT
  119.                                              -------------
  120.  
  121.    Global syntax of Menu XCMD is :
  122.  
  123.                     Menu <command> [<param 1>...,<param N>]
  124.  
  125.    New, Menu, item and subitem parameters are always name strings, but you can even use a number for item (the order in menu) and subitem (the order in submenu). Any of these parameters, except Menu name can use the standard formatting chars recognized by the File Mgr, either at the beginning or at the end of the name string :
  126.  
  127.      ^XXX    associates an ICON resource to the item
  128.      !X        puts a mark before the item
  129.      <X        sets the style of the item (B, I, O, U, S)
  130.                 NOTE : a bug in the Menu Mgr prevents using <E (extend) and <C 
  131.                            (condense) in the string. Using one of these will cause the 
  132.                            item to be ignored. Rather use SetStyle (see later).
  133.      /X       associates a command key to the item
  134.      (         disables the item
  135.  
  136. and a special hack :
  137.      ¬®XXX    associates an SICN resource to the item (¬® = option-u)
  138.  
  139.  
  140.   The first command parameter will determine the action of Menu XCMD :
  141.  
  142.  
  143. SWITCH
  144.  
  145.         Menu "Switch"[,<About item>[,<help item>]]
  146.  
  147.    Hides all HC menus, leaving only the Apple, File & Edit menus. About & Help items will be placed under the Apple menu, File has only a Quit item and Edit keeps all working clipboard handling items.
  148.    Called for the first times, Switch hides the HC menus. Called a second time, it restores the original menuBar.
  149. HINT : Whatever is the wording you choose for About item, HC 1.2.x sends doMenu "About HyperCard...". So do a correct test in your handler.
  150.  
  151.  
  152. REMOVE
  153.  
  154.         Menu "Remove",<menu|*>[,<item|*>[,<subitem|*>]]
  155.  
  156.   Removes one or all menus, items of a menu or subitems of a submenu. "*" stands for all when used in place of any parameter.
  157.  
  158.  
  159. INSTALL
  160.  
  161.         Menu "Install",<menu def>[‚Ķ,<menu def>]
  162.  
  163.    Installs one or many (up to ten) user menus in one call. MenuDef can any container or literal string containing :
  164.  
  165.         "Menu name
  166.          item 1, subitem 1.1,subitem 1.2
  167.          item 2
  168.          item 3, subitem 3.1"
  169.  
  170. or :
  171.  
  172. "Menu name;item 1, subitem 1.1,subitem 1.2;item 2;item 3, subitem 3.1"
  173.  
  174.  
  175. CHANGE
  176.  
  177.         Menu "Change",<new>,<menu>,<item>[,<subitem>]
  178.  
  179.    Changes the wording of any item or subitem. Using a comma separated list as new parameter, you can even add a submenu to any existing item, or with special formatting chars change its style, ICON, etc.
  180.  
  181.  
  182. INSERT
  183.  
  184.         Menu "Insert",<new>,<menu>,<before item|*>[,<before subitem|*>]
  185.  
  186.    Inserts a new item in a menu or a new subitem in a submenu. If you use 
  187. "*" as a param, the new item will be inserted at the end.
  188.  
  189.  
  190. CHECK/UNCHECK
  191.  
  192.         Menu "Check",<menu>,<item|*>[,<subitem|*>]
  193.         Menu "Uncheck",<menu>,<item|*>[,<subitem|*>]
  194.  
  195.    Checks or unchecks any item or subitem. "*" stands for all when used in place of any parameter, thus allowing to check all items in one call.
  196.  
  197.  
  198. ENABLE/DISABLE
  199.  
  200.         Menu "Enable",<menu>[,<item|*>[,<subitem|*>]]
  201.         Menu "Disable",<menu>[,<item|*>[,<subitem|*>]]
  202.  
  203.    Enables or disables a whole menu, or any item or subitem. "*" stands for all when used in place of any parameter, thus allowing to set all items in one call.
  204.  
  205.  
  206. FIND
  207.  
  208.         Menu "Find",<item or subitem>
  209.  
  210.    Allow to find in which menu/submenu is any item or subitem. You have to get the Result after calling to obtain a list of matching menus. Each line of the returned comma separated list contains a menu name, sometimes the submenu name and the number of the item in the menu or submenu..
  211.  
  212.  
  213. LIST
  214.  
  215.         Menu "List",<menu|*>[,<item|*>[,<*>]]
  216.  
  217.    GetList returns a list of menus, items or subitems. Depending on the params you pass, List wiil return :
  218.      Menu "List","*" ........................... comma separated list of menu names
  219.      Menu "List","menu"....................... menuDef of menu (see Install)
  220.      Menu "List","menu","*"................ list of items & subitems of menu
  221.      Menu "List","menu","item"............ item & list of subitems of submenu
  222.      Menu "List","menu","item","*"..... list of subitems of submenu
  223.  
  224.    You have to get the Result after calling to obtain the required list.
  225.    HINT : if the first item of the returned menus list is "File", then you already called Switch command.
  226.  
  227.  
  228. COUNT
  229.  
  230.         Menu "Count",<menu|*>[,<item|*>[,<*>]]
  231.  
  232.    Count returns the number of user menus, items in a menu or subitems in a submenu. Last param must always be "*". You have to get the Result after calling to obtain the resulting number.
  233.    If you ask for the number of menus after have called Switch, the File user menu will be one of the totalized menus. 
  234.  
  235.  
  236. ISCHECKED/ISENABLED
  237.  
  238.         Menu "IsChecked",<menu>,<item>[,<subitem>]
  239.         Menu "IsEnabled",<menu>[,<item>[,<subitem>]]
  240.  
  241.    Returns "true" or "false", allowing to know if the menu, item or subitem is checked or enables. You have to get the Result after calling to obtain the value.
  242.  
  243.  
  244. GETCMD/SETCMD
  245.  
  246.         Menu "GetCmd",<menu>,<item>[,<subitem>]
  247.         Menu "SetCmd",<Cmd char>,<menu>,<item>[,<subitem>]
  248.  
  249.    Returns or sets the command char of any item or subitem. You have to get the Result after calling GetCmd to obtain the cmd char.
  250.  
  251.  
  252. GETICON/SETICON
  253.  
  254.         Menu "GetIcon",<menu>,<item>[,<subitem>]
  255.         Menu "SetIcon",<ICON ID>,<menu>,<item>[,<subitem>]
  256.  
  257.    Returns or sets the associated ICON of any item or subitem. ICON ID must be greater than 256 but smaller than 512. You have to get the Result after calling GetIcon to obtain the ICON ID.
  258.  
  259.  
  260. GETSTYLE/SETSTYLE
  261.  
  262.         Menu "GetStyle",<menu>,<item>[,<subitem>]
  263.         Menu "SetStyle",<style>,<menu>,<item>[,<subitem>]
  264.  
  265.    Returns or sets the style of any item or subitem. You have to get the Result after calling GetStyle to obtain the style string.
  266.    Style is a one or many chars string which can contain :
  267. N (Normal), B (Bold), I (Italic), U (Underline), O (Outline), S (Shadow), 
  268. C (Condense), E (Extend)
  269.  
  270.  
  271. GETSICN/SETSICN
  272.  
  273.         Menu "GetSicn",<menu>,<item>[,<subitem>]
  274.         Menu "SetSicn",<SICN ID>,<menu>,<item>[,<subitem>]
  275.  
  276.    Returns or sets the associated SICN of any item or subitem. SICN ID must be greater than 256 but smaller than 512. You have to get the Result after calling GetSicn to obtain the SICN ID.
  277.  
  278.                                             ------------------
  279.  
  280. Finally, don't worry : the XCMD is really bullet-proof, and numerous errors strings are available in the Result when something goes wrong :
  281.  
  282.        "Error : Menu not found"
  283.        "Error : Bad ICON or SICN ID (257 ‚⧠x ‚⧠511)"
  284.        "Error : Item not found"
  285.        "Error : Subitem not found"
  286.        "Error : Missing parameter(s)"
  287.        "Error : Useless parameter(s)"
  288.        "Error : This item has no submenu"
  289.        "Error : File menu cannot be removed"
  290.        "Error : Quit item cannot be removed from File menu "
  291.        "Error : UserLevel must be ‚â• 4"
  292.        "Error : Couldn't save current Edit menu"
  293.        "Error : No more than 10 user menus"
  294.        "Error : Bad menu name in param #x"
  295.        "Error : Must call Switch before installing File menu"
  296.        "Error : "*" not allowed in Change params"
  297.        "Error : No more than one subMenu level"
  298.        "Error : "*" not allowed in menu param for Insert"
  299.        "Error : "*" not allowed in menu param for Check/Uncheck"
  300.        "Error : Quit item of File menu cannot be checked"
  301.        "Error : Whole File menu cannot be disabled"
  302.        "Error : Quit item of File menu cannot be disabled"
  303.        "Error : Out of Memory"
  304.        "Error : "*" not allowed in IsEnabled params"
  305.        "Error : "*" not allowed in IsChecked params"
  306.        "Error : "*" not allowed in Get... params"
  307.        "Error : "*" not allowed in Set... params"
  308.        "Error : SetCmd not allowed for Quit items of File menu"
  309.        "Error : SetCmd not allowed for items having a submenu"
  310.        "Error : SetSicn not allowed for items having a submenu"
  311.        "Error : Unknown command"
  312.        "Error : Empty param #x"
  313.        "Error : File menu resource not found"
  314.        "Error : SubMenu not allowed for About item"
  315.        "Error : SubMenu not allowed for Help item"
  316.        "Error : Duplicate menu name"
  317.  
  318. HISTORY
  319. -------
  320. 2.1                                                                                              8/15/91
  321. ‚Ä¢ Locked parameter block for HC 2.0
  322. ‚Ä¢ Changed submenus IDs to be HC 2.0 compatible
  323. ‚Ä¢ Cleaned the code
  324. ‚Ä¢ Added "=" online help param
  325. ---------------------------------------------------------------------
  326.  
  327. This (these) external(s) is (are) FreeWare,allowing unlimited use in any non-commercial stack. You just need in this case to mention the author's name and copyright in your stack.
  328. Any commercial use must be licensed and aknowledged by the author.
  329.  
  330.                               ¬© F. Rinaldi - 1989,1990,1991
  331.  
  332. AppleLink: RINALDI1        CalvaCom : FR10        Compuserve : 71170,2111